package com.mingyuan.library.provider.common.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 分页数据
 *
 * @param <T>
 */
public class PageData<T> extends DTO implements Serializable {

    private static final long serialVersionUID = 4851751671932274023L;
    /**
     * 总记录条数
     */
    private long total = 0L;

    /**
     * 分页查询到的集合
     */
    private List<T> list = new ArrayList<>();

    /**
     * 是否有下一页数据
     */
    private boolean hasNextPage = false;

    public PageData() {
    }

    public PageData(long total, List<T> list) {
        this.total = total;
        this.list = list;
    }

    public static <T> PageData<T> newInstance() {
        return new PageData<>();
    }

    public static <T> PageData<T> newInstance(long total, List<T> list) {
        return new PageData<>(total, list);
    }

    public long getTotal() {
        return total;
    }

    public PageData<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    public List<T> getList() {
        return list;
    }

    public PageData<T> setList(List<T> list) {
        this.list = list;
        return this;
    }

    public boolean isHasNextPage() {
        return hasNextPage;
    }

    public PageData<T> setHasNextPage(boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
        return this;
    }
}